﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing {
    import org.aswing.geom.*;

    public class ViewportLayout extends EmptyLayout {

        override public function preferredLayoutSize(_arg1:Container):IntDimension{
            var _local2:JViewport = JViewport(_arg1);
            var _local3:IntDimension;
            if (_local2.getView() != null){
                _local3 = _local2.getView().getPreferredSize();
            } else {
                _local3 = new IntDimension(0, 0);
            };
            return (_local2.getViewportPane().getInsets().getOutsideSize(_local3));
        }
        override public function layoutContainer(_arg1:Container):void{
            var _local2:JViewport = (_arg1 as JViewport);
            if (_local2 == null){
                return;
            };
            var _local3:Component = _local2.getView();
            if (_local3 == null){
                return;
            };
            var _local4:IntDimension = _local2.getExtentSize();
            var _local5:IntDimension = _local2.getViewSize();
            var _local6:IntPoint = _local2.getViewPosition();
            _local6.x = Math.round(_local6.x);
            _local6.y = Math.round(_local6.y);
            if ((_local6.x + _local4.width) > _local5.width){
                _local6.x = Math.max(0, (_local5.width - _local4.width));
            };
            if ((_local6.y + _local4.height) > _local5.height){
                _local6.y = Math.max(0, (_local5.height - _local4.height));
            };
            _local2.setViewPosition(_local6);
            _local3.setSize(_local5);
        }

    }
}//package org.aswing 
